﻿using MS.InformationManagement.Presenter.Support;
using MS.InformationManagement.BLL.SimpleSearch;

namespace MS.InformationManagement.Presenter.SimpleSearch
{
    public class SimpleSearchPresenter : BasePresenter<ISimpleSearchView>
    {
        public SimpleSearchPresenter(ISimpleSearchView view) : base(view) { }

        public void ExecuteSimpleSearch(bool save)
        {
            int totalExecutionTime;
            int totalRecords;
            View.CurrentPageResultSet = new SimpleSearchBLL().ExecuteSimpleSearch(View.SearchCriteria, View.PageIndex, View.PageSize
                , out totalRecords, out totalExecutionTime);
            View.TotalExecutionTime = totalExecutionTime;
            View.TotalRecords = totalRecords;
            if (save && !string.IsNullOrEmpty(View.SearchCriteria)) {
                SimpleSearchBLL.SaveSimpleSearchHistory(View.SearchCriteria);
            }
        }
    }
}
